package com.tma.demoremoteservice;

import a.thread.ThreadUtil;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

public class MyRemoteService extends Service {
    static final String TAG = "MyRemoteService";

    private class StockQuoteServiceImpl extends IStockQuoteService.Stub {

        @Override
        public String getQuote(String ticker, Person requester)
                throws RemoteException {
            Log.i("StockQuoteServiceImpl", "getQuote");
            ThreadUtil.logThreadSignature("StockQuoteServiceImpl");
            return "Hello " + requester.getName() + 
                    "! Quote for " + ticker + " is 20.0"; 
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        ThreadUtil.logThreadSignature("MyRemoteService");
        Log.i(TAG, "Remote Service: onCreate");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ThreadUtil.logThreadSignature("MyRemoteService");
        Log.i(TAG, "Remote Service: onDestroy");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "Remote Service: onStartCommand");
        ThreadUtil.logThreadSignature("MyRemoteService");
        return Service.START_STICKY;
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "Remote Service: onBind");
        return new StockQuoteServiceImpl();
    }

}
